﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Interface;

namespace Model
{
    public class FbmDataCollection // This class is written by Per Leth Andersen, edited by Tien - may 8th
    {
        public List<FbmData> DataCol { get; set; }

        public FbmDataCollection()
        {
            DataCol = new List<FbmData>();
        }

        #region Methods
        public FbmData Add(int id, IFbmReport fbmrid, IFbmFeature fbmfid, double measured, double deviation, bool test)
        {
            FbmData fbmData = new FbmData(id, fbmrid, fbmfid, measured, deviation, test);
            DataCol.Add(fbmData);
            return fbmData;
        }
        public IFbmData Find(int id)
        {
            int max = DataCol.Count;
            int min = 0;
            while (max >= min)
            {
                int mid = (min + max) / 2;
                if (DataCol[mid].Id < id)
                    min = mid + 1;
                else if (DataCol[mid].Id > id)
                    max = mid - 1;
                else
                    return (IFbmData)DataCol[mid];
            }
            return null;
        }
        #endregion
    }
}